const { JSDOM } = require("jsdom");

const ShopIndex = ({ res, response }) => {
  res.setHeader("Content-Type", "application/json");
  try {
    const dom = new JSDOM(response);
    const document = dom.window.document;
    const Price = document.match(/点券\[(.*?)\]/)[1];

    return JSON.stringify({
      data: Price,
      success: true,
    });
  } catch (error) {
    return JSON.stringify({
      success: false,
    });
  }
};

module.exports = {
  ShopIndex,
};
